package com.framework.core.mybatis.context;

import lombok.Builder;
import lombok.Data;
import org.apache.ibatis.type.JdbcType;

import java.util.ArrayList;
import java.util.List;

/**
 *  表名和字段->构成整个表
 *  created by zzg
 *  2024-12-06
 */
@Data
@Builder
public class TableInfo {
    private String tableName;
    private List<FieldInfo> fieldInfoList;

    public void addField(String value, String property, String comment, boolean isPrimaryKey, boolean isVersion, JdbcType jdbcType) {
        FieldInfo fieldInfo = FieldInfo.builder()
                .value(value)
                .property(property)
                .comment(comment)
                .primaryKey(isPrimaryKey)
                .version(isVersion)
                .jdbcType(jdbcType)
                .build();
        if (null == fieldInfoList) {
            fieldInfoList = new ArrayList<>(16);
        }
        fieldInfoList.add(fieldInfo);
    }
}
